/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Control;

import Model.TableLexema;
import Model.Token;
import Model.symtable.Symtable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Alan Carlos
 */
public class Parser {
    private Token currentToken; 
    private Gramatica gramatica;
    private int currentIndex;
    private Iterator<Token> itToken;
    private ArrayList<Token> listToken;
    private Symtable tabelaSimbolos;
    public Parser(){
        
            tabelaSimbolos = new Symtable();
            listToken=TableLexema.getInstance().getArray();
            itToken = TableLexema.getInstance().getArray().iterator();
            nextToken();
            gramatica = new Gramatica(this,tabelaSimbolos);
            //gramatica.expressaoAritmetica(";");
            //gramatica.expressaoLogica(";");
            //gramatica.expressaoRelacional(";");
            //gramatica.atribuicao(";");
            //gramatica.definicaoConstante("variables");
            
            //gramatica.inicializaObjeto(";");
            //gramatica.comandoIf(";");
            //gramatica.comandoWhile(";");
            //gramatica.comandoFor(";");
              //gramatica.write(";");
            //gramatica.read(";");        
            gramatica.inicio("");
            System.out.println("Done");
        
        
    }
    public void start(){
       
       
        
    }

    public Token getCurrentToken() {
        return currentToken;
    }
    public Token nextToken() {
        if (itToken.hasNext()) {            
            currentToken = itToken.next();
            return currentToken;    
        }
        else{
            System.out.println("Fim da cadeia");
            currentToken =  new Token("EOF", 0, 0, 0,0);
            return currentToken;
            //throw new EndASException("End");
            //return null;
        }
        
    }

    public Iterator<Token> getItToken() {
        return itToken;
    }

    public ArrayList<Token> getListToken() {
        return listToken;
    }
    
}
